|
|
Okay, I just made something which will allow a bit of variation in the reward. Basically I used random for a value from 0-25, divided that by 100 (for a percent), and then multiply the reward per item by said value.
But then I realized that there would be a slight problem. The small bits leftover after this does it's work.
So is there a way to have a number round up or round down? I really don't think the game will like a reward of 53.249325230948214 gold
Post Extras:
|
Mode_Locrian
|
Diviner
|
|
|
Reged: 10/07/02
|
Posts: 2084
|
Loc: Bjornholm, Rykith Lowlands Region
|
|
|
I'm pretty sure the game will round it automatically for you.
Otherwise, just make a short variable and store the random number into this variable after you're done calculating it. It won't round the number, but it will just truncate everything after the decimal point (e.g. 5.84362718 becomes 5).
-------------------- My Website
Bards of Vvardenfell Thread (New Info 8/15/04)
Post Extras:
|
|
|
works for me
Thanks.
Post Extras:
|
|
|
If you want it to be rounded, do the previously mentioned method but have it add .5 to the number first. That will allow it to round up if the number ends in .5 or higher, and if not, it'll leave the number as is.
-------------------- Never laugh at a live dragon.
--Bilbo Baggins, There and Back Again: a Hobbit's Tale (a.k.a. The Hobbit)
Nerds rule the world. No one else knows it yet.
Post Extras:
|
Klinn
|
Diviner
|
|
|
Reged: 11/19/02
|
Posts: 2319
|
|
|
|
Just to be really finicky about this , adding .5 to all numbers will lead to an uneven distribution of results. All numbers which end with exactly ##.5 will always be rounded up. For even distribution, half should be rounded down and half should be rounded up. To avoid this, you can use a procedure such as: "add 0.4999999 to all even numbers, add 0.5 to all odd numbers"
In practice, for Morrowind scripting, this is not needed. If you're venturing into the wooly world of statistics, it becomes more important.
...Klinn
Post Extras:
|
cyran0
|
Initiate
|
|
|
Reged: 06/04/04
|
Posts: 58
|
|
|
|
With or without, adding the 0.5 is a sweet trick
Post Extras:
|